/* Copyright 2018 JDCLOUD.COM

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http:#www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Consumption Management APIs
消费管理API接口

OpenAPI spec version: v1
Contact: 

NOTE: This class is auto generated by the jdcloud code generator program.
*/

#import <Foundation/Foundation.h>
#import <JDCloudOCSDKBilling/BillingApiModel.h>


@implementation BillingCalculateTotalPriceRequest
-(id) initWithRegion:(NSString *)regionId
cmd:(NSNumber*)cmd
orderList:(NSArray<OrderPriceProtocol*>*)orderList
operateTime:(NSString*)operateTime
promotionInfo:(NSString*)promotionInfo
clientType:(NSNumber*)clientType
packageCount:(NSNumber*)packageCount
processType:(NSNumber*)processType { 
    self.regionId = regionId;
    self.cmd = cmd;
    self.orderList = orderList;
    self.operateTime = operateTime;
    self.promotionInfo = promotionInfo;
    self.clientType = clientType;
    self.packageCount = packageCount;
    self.processType = processType;
    return self;
}

-(id) initWithRegion:(NSString *)regionId
             version:(NSString *)version
cmd:(NSNumber*)cmd
orderList:(NSArray<OrderPriceProtocol*>*)orderList
operateTime:(NSString*)operateTime
promotionInfo:(NSString*)promotionInfo
clientType:(NSNumber*)clientType
packageCount:(NSNumber*)packageCount
processType:(NSNumber*)processType { 
    self.regionId = regionId;
    self.version = version;
    self.cmd = cmd;
    self.orderList = orderList;
    self.operateTime = operateTime;
    self.promotionInfo = promotionInfo;
    self.clientType = clientType;
    self.packageCount = packageCount;
    self.processType = processType;
    return self;
}
-(NSMutableDictionary*) dictionary{
    NSMutableDictionary* result = [[NSMutableDictionary alloc] init];
    NSMutableDictionary *superObjectDic = [super dictionary];
    if(superObjectDic && [superObjectDic count]>0)
    {
        [result addEntriesFromDictionary:superObjectDic];
    }
    if([self cmd])
    {
        [result setValue:[self cmd] forKey:@"cmd"];
    }
    if([self orderList])
    {
            NSMutableArray<NSDictionary*>* arrayDic  = [[NSMutableArray alloc] init];
            for (int i =0 ; i< [[self orderList] count]; i++) {
            OrderPriceProtocol* item = [[self orderList] objectAtIndex:i];
            [arrayDic addObject:[item dictionary]];
        }
        [result setValue:arrayDic forKey:@"orderList"];
    }
    if([self operateTime])
    {
        [result setValue:[self operateTime] forKey:@"operateTime"];
    }
    if([self promotionInfo])
    {
        [result setValue:[self promotionInfo] forKey:@"promotionInfo"];
    }
    if([self clientType])
    {
        [result setValue:[self clientType] forKey:@"clientType"];
    }
    if([self packageCount])
    {
        [result setValue:[self packageCount] forKey:@"packageCount"];
    }
    if([self processType])
    {
        [result setValue:[self processType] forKey:@"processType"];
    }
    return result;
}

-(id) initWithDic:(NSDictionary*)dictionary{
    self.cmd = [dictionary objectForKey:@"cmd"];
    NSArray* orderListArray = [dictionary objectForKey:@"orderList"];
    if(orderListArray&&![orderListArray isKindOfClass:[NSNull class]])
    {
        NSMutableArray* propertyArray = [[NSMutableArray alloc]init];
        for(int i = 0 ; i< [orderListArray count];i++)
        {
        OrderPriceProtocol* item = [[OrderPriceProtocol alloc]initWithDic:[orderListArray objectAtIndex:i]];
            if(item)
            {
            [propertyArray addObject:item];
            }
        }
        self.orderList = propertyArray;
    }
    self.operateTime = [dictionary objectForKey:@"operateTime"];
    self.promotionInfo = [dictionary objectForKey:@"promotionInfo"];
    self.clientType = [dictionary objectForKey:@"clientType"];
    self.packageCount = [dictionary objectForKey:@"packageCount"];
    self.processType = [dictionary objectForKey:@"processType"];
    return self;
} 

@end
@implementation BillingCalculateTotalPriceResult
-(id) initWithTotalPrice:(NSNumber*) totalPrice
        totalPriceScale4:(NSNumber*)totalPriceScale4
        discountedTotalPrice:(NSNumber*)discountedTotalPrice
        totalDiscount:(NSNumber*)totalDiscount
        list:(NSArray<OrderPriceDetail*>*)list
        totalOriginalPrice:(NSNumber*)totalOriginalPrice
        favorableInfos:(NSString*)favorableInfos
        remark:(NSString*)remark
        totalUnitPrice:(NSNumber*)totalUnitPrice { 
    self.totalPrice = totalPrice;               
    self.totalPriceScale4 = totalPriceScale4;               
    self.discountedTotalPrice = discountedTotalPrice;               
    self.totalDiscount = totalDiscount;               
    self.list = list;               
    self.totalOriginalPrice = totalOriginalPrice;               
    self.favorableInfos = favorableInfos;               
    self.remark = remark;               
    self.totalUnitPrice = totalUnitPrice;               
    return self;
}
-(NSMutableDictionary*) dictionary{
    NSMutableDictionary* result = [[NSMutableDictionary alloc] init];
    if([self totalPrice])
    {
        [result setValue:[self totalPrice] forKey:@"totalPrice"];
    }
    if([self totalPriceScale4])
    {
        [result setValue:[self totalPriceScale4] forKey:@"totalPriceScale4"];
    }
    if([self discountedTotalPrice])
    {
        [result setValue:[self discountedTotalPrice] forKey:@"discountedTotalPrice"];
    }
    if([self totalDiscount])
    {
        [result setValue:[self totalDiscount] forKey:@"totalDiscount"];
    }
    if([self list])
    {
            NSMutableArray<NSDictionary*>* arrayDic  = [[NSMutableArray alloc] init];
            for (int i =0 ; i< [[self list] count]; i++) {
            OrderPriceDetail* item = [[self list] objectAtIndex:i];
            [arrayDic addObject:[item dictionary]];
        }
        [result setValue:arrayDic forKey:@"list"];
    }
    if([self totalOriginalPrice])
    {
        [result setValue:[self totalOriginalPrice] forKey:@"totalOriginalPrice"];
    }
    if([self favorableInfos])
    {
        [result setValue:[self favorableInfos] forKey:@"favorableInfos"];
    }
    if([self remark])
    {
        [result setValue:[self remark] forKey:@"remark"];
    }
    if([self totalUnitPrice])
    {
        [result setValue:[self totalUnitPrice] forKey:@"totalUnitPrice"];
    }
    return result;
}

-(id) initWithDic:(NSDictionary*)dictionary{
    self.totalPrice = [dictionary objectForKey:@"totalPrice"];
    self.totalPriceScale4 = [dictionary objectForKey:@"totalPriceScale4"];
    self.discountedTotalPrice = [dictionary objectForKey:@"discountedTotalPrice"];
    self.totalDiscount = [dictionary objectForKey:@"totalDiscount"];
    NSArray* listArray = [dictionary objectForKey:@"list"];
    if(listArray&&![listArray isKindOfClass:[NSNull class]])
    {
        NSMutableArray* propertyArray = [[NSMutableArray alloc]init];
        for(int i = 0 ; i< [listArray count];i++)
        {
        OrderPriceDetail* item = [[OrderPriceDetail alloc]initWithDic:[listArray objectAtIndex:i]];
            if(item)
            {
            [propertyArray addObject:item];
            }
        }
        self.list = propertyArray;
    }
    self.totalOriginalPrice = [dictionary objectForKey:@"totalOriginalPrice"];
    self.favorableInfos = [dictionary objectForKey:@"favorableInfos"];
    self.remark = [dictionary objectForKey:@"remark"];
    self.totalUnitPrice = [dictionary objectForKey:@"totalUnitPrice"];
    return self;
} 

@end
  
@implementation BillingCalculateTotalPriceResponse
-(NSMutableDictionary*) dictionary
{
    NSMutableDictionary* result = [[NSMutableDictionary alloc] init]; 
    if([self requestId])
    {
        [result setValue:[self requestId] forKey:@"requestId"];
    } 
    if([self result])
    {
        
        [result setValue:[[self result] dictionary] forKey:@"result"];
    }
    if([self error])
    {
        
        [result setValue:[[self error] dictionary] forKey:@"error"];
    }
    return result;
}

-(id) initWithDic:(NSDictionary*)dictionary
{
    
    self.requestId = [dictionary objectForKey:@"requestId"];
BillingCalculateTotalPriceResult* result = [[BillingCalculateTotalPriceResult alloc]initWithDic:[dictionary objectForKey:@"result"]];
    self.result = result;
    ServiceError* error = [[ServiceError alloc]initWithDic:[dictionary objectForKey:@"error"]];
    self.error = error;
    return self;
}

-(id) initWithRequestId:(NSString*) requestId
                  error:(ServiceError*) error
                 result:(BillingCalculateTotalPriceResult*) result
{
    self.error = error;
    self.result =result;
    self.requestId = requestId;
    return self;
}

@end
@implementation BillingQueryBillSummaryResult
-(id) initWithPagination:(Pagination*) pagination
        result:(NSArray<BillSummary*>*)result { 
    self.pagination = pagination;               
    self.result = result;               
    return self;
}
-(NSMutableDictionary*) dictionary{
    NSMutableDictionary* result = [[NSMutableDictionary alloc] init];
    if([self pagination])
    {
        [result setValue:[[self pagination] dictionary]forKey:@"pagination"];
    }
    if([self result])
    {
            NSMutableArray<NSDictionary*>* arrayDic  = [[NSMutableArray alloc] init];
            for (int i =0 ; i< [[self result] count]; i++) {
            BillSummary* item = [[self result] objectAtIndex:i];
            [arrayDic addObject:[item dictionary]];
        }
        [result setValue:arrayDic forKey:@"result"];
    }
    return result;
}

-(id) initWithDic:(NSDictionary*)dictionary{
    self.pagination = [[Pagination alloc]initWithDic:[dictionary objectForKey:@"pagination"]];
    NSArray* resultArray = [dictionary objectForKey:@"result"];
    if(resultArray&&![resultArray isKindOfClass:[NSNull class]])
    {
        NSMutableArray* propertyArray = [[NSMutableArray alloc]init];
        for(int i = 0 ; i< [resultArray count];i++)
        {
        BillSummary* item = [[BillSummary alloc]initWithDic:[resultArray objectAtIndex:i]];
            if(item)
            {
            [propertyArray addObject:item];
            }
        }
        self.result = propertyArray;
    }
    return self;
} 

@end
@implementation BillingQueryBillDetailResult
-(id) initWithPagination:(Pagination*) pagination
        result:(NSArray<BillSummary*>*)result { 
    self.pagination = pagination;               
    self.result = result;               
    return self;
}
-(NSMutableDictionary*) dictionary{
    NSMutableDictionary* result = [[NSMutableDictionary alloc] init];
    if([self pagination])
    {
        [result setValue:[[self pagination] dictionary]forKey:@"pagination"];
    }
    if([self result])
    {
            NSMutableArray<NSDictionary*>* arrayDic  = [[NSMutableArray alloc] init];
            for (int i =0 ; i< [[self result] count]; i++) {
            BillSummary* item = [[self result] objectAtIndex:i];
            [arrayDic addObject:[item dictionary]];
        }
        [result setValue:arrayDic forKey:@"result"];
    }
    return result;
}

-(id) initWithDic:(NSDictionary*)dictionary{
    self.pagination = [[Pagination alloc]initWithDic:[dictionary objectForKey:@"pagination"]];
    NSArray* resultArray = [dictionary objectForKey:@"result"];
    if(resultArray&&![resultArray isKindOfClass:[NSNull class]])
    {
        NSMutableArray* propertyArray = [[NSMutableArray alloc]init];
        for(int i = 0 ; i< [resultArray count];i++)
        {
        BillSummary* item = [[BillSummary alloc]initWithDic:[resultArray objectAtIndex:i]];
            if(item)
            {
            [propertyArray addObject:item];
            }
        }
        self.result = propertyArray;
    }
    return self;
} 

@end
@implementation BillingQueryBillSummaryRequest
-(id) initWithRegion:(NSString *)regionId
startTime:(NSString*)startTime
endTime:(NSString*)endTime
appCode:(NSString*)appCode
serviceCode:(NSString*)serviceCode
resourceIds:(NSArray<NSString*>*)resourceIds
tags:(NSArray<Tags*>*)tags
pageIndex:(NSNumber*)pageIndex
pageSize:(NSNumber*)pageSize { 
    self.regionId = regionId;
    self.startTime = startTime;
    self.endTime = endTime;
    self.appCode = appCode;
    self.serviceCode = serviceCode;
    self.resourceIds = resourceIds;
    self.tags = tags;
    self.pageIndex = pageIndex;
    self.pageSize = pageSize;
    return self;
}

-(id) initWithRegion:(NSString *)regionId
             version:(NSString *)version
startTime:(NSString*)startTime
endTime:(NSString*)endTime
appCode:(NSString*)appCode
serviceCode:(NSString*)serviceCode
resourceIds:(NSArray<NSString*>*)resourceIds
tags:(NSArray<Tags*>*)tags
pageIndex:(NSNumber*)pageIndex
pageSize:(NSNumber*)pageSize { 
    self.regionId = regionId;
    self.version = version;
    self.startTime = startTime;
    self.endTime = endTime;
    self.appCode = appCode;
    self.serviceCode = serviceCode;
    self.resourceIds = resourceIds;
    self.tags = tags;
    self.pageIndex = pageIndex;
    self.pageSize = pageSize;
    return self;
}
-(NSMutableDictionary*) dictionary{
    NSMutableDictionary* result = [[NSMutableDictionary alloc] init];
    NSMutableDictionary *superObjectDic = [super dictionary];
    if(superObjectDic && [superObjectDic count]>0)
    {
        [result addEntriesFromDictionary:superObjectDic];
    }
    if([self startTime])
    {
        [result setValue:[self startTime] forKey:@"startTime"];
    }
    if([self endTime])
    {
        [result setValue:[self endTime] forKey:@"endTime"];
    }
    if([self appCode])
    {
        [result setValue:[self appCode] forKey:@"appCode"];
    }
    if([self serviceCode])
    {
        [result setValue:[self serviceCode] forKey:@"serviceCode"];
    }
    if([self resourceIds])
    {
        [result setValue:[self resourceIds] forKey:@"resourceIds"];
    }
    if([self tags])
    {
            NSMutableArray<NSDictionary*>* arrayDic  = [[NSMutableArray alloc] init];
            for (int i =0 ; i< [[self tags] count]; i++) {
            Tags* item = [[self tags] objectAtIndex:i];
            [arrayDic addObject:[item dictionary]];
        }
        [result setValue:arrayDic forKey:@"tags"];
    }
    if([self pageIndex])
    {
        [result setValue:[self pageIndex] forKey:@"pageIndex"];
    }
    if([self pageSize])
    {
        [result setValue:[self pageSize] forKey:@"pageSize"];
    }
    return result;
}

-(id) initWithDic:(NSDictionary*)dictionary{
    self.startTime = [dictionary objectForKey:@"startTime"];
    self.endTime = [dictionary objectForKey:@"endTime"];
    self.appCode = [dictionary objectForKey:@"appCode"];
    self.serviceCode = [dictionary objectForKey:@"serviceCode"];
    self.resourceIds = [dictionary objectForKey:@"resourceIds"];
    NSArray* tagsArray = [dictionary objectForKey:@"tags"];
    if(tagsArray&&![tagsArray isKindOfClass:[NSNull class]])
    {
        NSMutableArray* propertyArray = [[NSMutableArray alloc]init];
        for(int i = 0 ; i< [tagsArray count];i++)
        {
        Tags* item = [[Tags alloc]initWithDic:[tagsArray objectAtIndex:i]];
            if(item)
            {
            [propertyArray addObject:item];
            }
        }
        self.tags = propertyArray;
    }
    self.pageIndex = [dictionary objectForKey:@"pageIndex"];
    self.pageSize = [dictionary objectForKey:@"pageSize"];
    return self;
} 

@end
  
@implementation BillingQueryBillSummaryResponse
-(NSMutableDictionary*) dictionary
{
    NSMutableDictionary* result = [[NSMutableDictionary alloc] init]; 
    if([self requestId])
    {
        [result setValue:[self requestId] forKey:@"requestId"];
    } 
    if([self result])
    {
        
        [result setValue:[[self result] dictionary] forKey:@"result"];
    }
    if([self error])
    {
        
        [result setValue:[[self error] dictionary] forKey:@"error"];
    }
    return result;
}

-(id) initWithDic:(NSDictionary*)dictionary
{
    
    self.requestId = [dictionary objectForKey:@"requestId"];
BillingQueryBillSummaryResult* result = [[BillingQueryBillSummaryResult alloc]initWithDic:[dictionary objectForKey:@"result"]];
    self.result = result;
    ServiceError* error = [[ServiceError alloc]initWithDic:[dictionary objectForKey:@"error"]];
    self.error = error;
    return self;
}

-(id) initWithRequestId:(NSString*) requestId
                  error:(ServiceError*) error
                 result:(BillingQueryBillSummaryResult*) result
{
    self.error = error;
    self.result =result;
    self.requestId = requestId;
    return self;
}

@end
  
@implementation BillingQueryBillDetailResponse
-(NSMutableDictionary*) dictionary
{
    NSMutableDictionary* result = [[NSMutableDictionary alloc] init]; 
    if([self requestId])
    {
        [result setValue:[self requestId] forKey:@"requestId"];
    } 
    if([self result])
    {
        
        [result setValue:[[self result] dictionary] forKey:@"result"];
    }
    if([self error])
    {
        
        [result setValue:[[self error] dictionary] forKey:@"error"];
    }
    return result;
}

-(id) initWithDic:(NSDictionary*)dictionary
{
    
    self.requestId = [dictionary objectForKey:@"requestId"];
BillingQueryBillDetailResult* result = [[BillingQueryBillDetailResult alloc]initWithDic:[dictionary objectForKey:@"result"]];
    self.result = result;
    ServiceError* error = [[ServiceError alloc]initWithDic:[dictionary objectForKey:@"error"]];
    self.error = error;
    return self;
}

-(id) initWithRequestId:(NSString*) requestId
                  error:(ServiceError*) error
                 result:(BillingQueryBillDetailResult*) result
{
    self.error = error;
    self.result =result;
    self.requestId = requestId;
    return self;
}

@end
@implementation BillingQueryBillDetailRequest
-(id) initWithRegion:(NSString *)regionId
startTime:(NSString*)startTime
endTime:(NSString*)endTime
appCode:(NSString*)appCode
serviceCode:(NSString*)serviceCode
billingType:(NSNumber*)billingType
resourceIds:(NSArray<NSString*>*)resourceIds
tags:(NSArray<Tags*>*)tags
pageIndex:(NSNumber*)pageIndex
pageSize:(NSNumber*)pageSize { 
    self.regionId = regionId;
    self.startTime = startTime;
    self.endTime = endTime;
    self.appCode = appCode;
    self.serviceCode = serviceCode;
    self.billingType = billingType;
    self.resourceIds = resourceIds;
    self.tags = tags;
    self.pageIndex = pageIndex;
    self.pageSize = pageSize;
    return self;
}

-(id) initWithRegion:(NSString *)regionId
             version:(NSString *)version
startTime:(NSString*)startTime
endTime:(NSString*)endTime
appCode:(NSString*)appCode
serviceCode:(NSString*)serviceCode
billingType:(NSNumber*)billingType
resourceIds:(NSArray<NSString*>*)resourceIds
tags:(NSArray<Tags*>*)tags
pageIndex:(NSNumber*)pageIndex
pageSize:(NSNumber*)pageSize { 
    self.regionId = regionId;
    self.version = version;
    self.startTime = startTime;
    self.endTime = endTime;
    self.appCode = appCode;
    self.serviceCode = serviceCode;
    self.billingType = billingType;
    self.resourceIds = resourceIds;
    self.tags = tags;
    self.pageIndex = pageIndex;
    self.pageSize = pageSize;
    return self;
}
-(NSMutableDictionary*) dictionary{
    NSMutableDictionary* result = [[NSMutableDictionary alloc] init];
    NSMutableDictionary *superObjectDic = [super dictionary];
    if(superObjectDic && [superObjectDic count]>0)
    {
        [result addEntriesFromDictionary:superObjectDic];
    }
    if([self startTime])
    {
        [result setValue:[self startTime] forKey:@"startTime"];
    }
    if([self endTime])
    {
        [result setValue:[self endTime] forKey:@"endTime"];
    }
    if([self appCode])
    {
        [result setValue:[self appCode] forKey:@"appCode"];
    }
    if([self serviceCode])
    {
        [result setValue:[self serviceCode] forKey:@"serviceCode"];
    }
    if([self billingType])
    {
        [result setValue:[self billingType] forKey:@"billingType"];
    }
    if([self resourceIds])
    {
        [result setValue:[self resourceIds] forKey:@"resourceIds"];
    }
    if([self tags])
    {
            NSMutableArray<NSDictionary*>* arrayDic  = [[NSMutableArray alloc] init];
            for (int i =0 ; i< [[self tags] count]; i++) {
            Tags* item = [[self tags] objectAtIndex:i];
            [arrayDic addObject:[item dictionary]];
        }
        [result setValue:arrayDic forKey:@"tags"];
    }
    if([self pageIndex])
    {
        [result setValue:[self pageIndex] forKey:@"pageIndex"];
    }
    if([self pageSize])
    {
        [result setValue:[self pageSize] forKey:@"pageSize"];
    }
    return result;
}

-(id) initWithDic:(NSDictionary*)dictionary{
    self.startTime = [dictionary objectForKey:@"startTime"];
    self.endTime = [dictionary objectForKey:@"endTime"];
    self.appCode = [dictionary objectForKey:@"appCode"];
    self.serviceCode = [dictionary objectForKey:@"serviceCode"];
    self.billingType = [dictionary objectForKey:@"billingType"];
    self.resourceIds = [dictionary objectForKey:@"resourceIds"];
    NSArray* tagsArray = [dictionary objectForKey:@"tags"];
    if(tagsArray&&![tagsArray isKindOfClass:[NSNull class]])
    {
        NSMutableArray* propertyArray = [[NSMutableArray alloc]init];
        for(int i = 0 ; i< [tagsArray count];i++)
        {
        Tags* item = [[Tags alloc]initWithDic:[tagsArray objectAtIndex:i]];
            if(item)
            {
            [propertyArray addObject:item];
            }
        }
        self.tags = propertyArray;
    }
    self.pageIndex = [dictionary objectForKey:@"pageIndex"];
    self.pageSize = [dictionary objectForKey:@"pageSize"];
    return self;
} 

@end
 
